package net.kazed.nextaction.database.serialize;

import java.util.Stack;

/**
 * State of XML parser.
 * 
 * @author Koert Zeilstra
 */
public class ParserState {

    private Stack<ElementHandler> handlerStack;

    /**
     * Constructor.
     */
    public ParserState() {
        super();
        handlerStack = new Stack<ElementHandler>();
    }

    /**
     * @return Current ElementHandler.
     */
    public ElementHandler getCurrentElementHandler() {
        return handlerStack.peek();
    }

    /**
     * Push elementHandler on stack.
     * @param elementHandler Element handler.
     */
    public void pushElementHandler(ElementHandler elementHandler) {
        handlerStack.push(elementHandler);
    }
    
    /**
     * Pop element handler from stack.
     * @return Popped element handler.
     */
    public ElementHandler popElementHandler() {
        return handlerStack.pop();
    }
}
